Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AUDIO_WORKLET] Reword API to make it clearer #22741

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

cwoffenden
Copy link
Contributor

@cwoffenden cwoffenden commented Oct 15, 2024

Following from @juj 's suggestion in #22681, the use of quantum has been reduced to only where it refers to the API. Internally it's named samplesPerChannel to match the numberOfChannels in the AudioSampleFrame.

(This is entirely optional and doesn't change anything other than the naming.)

@sbc100
Copy link
Collaborator

sbc100 commented Oct 15, 2024

Does this not break the public API though? Maybe that is OK since this API is so new? @juj

@cwoffenden
Copy link
Contributor Author

cwoffenden commented Oct 15, 2024

Does this not break the public API though? Maybe that is OK since this API is so new? @juj

It does break it, but it's a few hours old. I cogitated over juj's suggestions after the PR had landed, since the naming also irked me, and thought it worth doing.

(It doesn't break any code older than these few hours though, and nothing in a release)

@sbc100
Copy link
Collaborator

sbc100 commented Oct 15, 2024

Does this not break the public API though? Maybe that is OK since this API is so new? @juj

It does break it, but it's a few hours old. I cogitated over juj's suggestions after the PR had landed, since the naming also irked me, and thought it worth doing.

Oh I see! LGTM then!

(It doesn't break any code older than these few hours though, and nothing in a release)

src/audio_worklet.js Outdated Show resolved Hide resolved
@@ -117,7 +117,7 @@ function createWasmAudioWorkletProcessor(audioParams) {
// not have one, so manually copy all bytes in)
for (i of outputList) {
for (j of i) {
for (k = 0; k < this.quantumSize; ++k) {
for (k = 0; k < this.samplesPerChannel; ++k) {
j[k] = HEAPF32[outputDataPtr++];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is each sample always an f32?

Copy link
Contributor Author

@cwoffenden cwoffenden Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the web API yes, and currently never interleaved. This float by float copy is how it was originally; see my other PR: #22753

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but lets wait for @juj to chime in

Copy link
Collaborator

@juj juj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I now realize that by parameterizing this, the compiler will lose the ability to optimize a multiplication into a shift. I.e. previously ch*128+i could be turned into a (ch<<7)|i by the compiler, but now it will be a true multiplication and add per each sample.

Maybe that will not be meaningful per-wise, although there is about 2.6 msecs to process each of these callbacks, so people won't want any wasted cycles.. hm...

Anyhow, this rename looks good.

@juj juj merged commit f6ed386 into emscripten-core:main Oct 17, 2024
28 checks passed
@cwoffenden
Copy link
Contributor Author

I now realize that by parameterizing this, the compiler will lose the ability to optimize a multiplication into a shift.

I can rewrite the examples later to work with offsets and some adds. Something like that.

@cwoffenden cwoffenden deleted the cw-audio-tweaks-2 branch October 17, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants